<%-- 
    Document   : loginpage
    Created on : 26-nov-2012, 18:55:25
    Author     : kjeld
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" import="models.Bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <link href="/style/general.css" type="text/css" rel="Stylesheet">
                <link href="/style/student.css" type="text/css" rel="Stylesheet"> 
                    <link rel="stylesheet" href="style/slideshow.css" />
                    <!-- include jQuery Library From Google Code -->
                    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>

                    <script type="text/javascript">

                        $(document).ready(function ()
                        {
                            $("#newTopic").click(function(e){
                                ShowDialog(true);
                                e.preventDefault();
                            });

                            $("#closeNewTopic").click(function (e)
                            {
                                HideDialog();
                                e.preventDefault();
                            });

                            $("#btnSubmit").click(function (e)
                            {
                                var brand = $("#brands input:radio:checked").val();
                                $("#output").html("<b>Your favorite mobile brand: </b>" + brand);
                                HideDialog();
                                e.preventDefault();
                            });

                        });

                        function ShowDialog(modal)
                        {
                            $("#overlay").show();
                            $("#dialog").fadeIn(300);

                            if (modal)
                            {
                                $("#overlay").unbind("click");
                            }
                            else
                            {
                                $("#overlay").click(function (e)
                                {
                                    HideDialog();
                                });
                            }
                        }

                        function HideDialog()
                        {
                            $("#overlay").hide();
                            $("#dialog").fadeOut(300);
                        }
       
                    </script>

                    <jsp:useBean id="inhoud" scope="application" class="models.Bean" />   
                    <jsp:setProperty name="inhoud" property="language" value="<%= models.Bean.getLanguage()%>" />

                    <title>
                        Three 2 Learn
                    </title>
                    <!-- The main style sheet -->
                    <link rel="stylesheet" href="/style/login.css" type="text/css" media="screen" />

                    </head>

                    <body>
                        <div id="container">

                            <div id="wrapper">
                                <div id="header">
                                    <div id="topmenu">
                                        <ul class="login">
                                            <li><img src="style/logo32L.png"/></li>
                                            <li><a href="/language?lang=nl" title="Nederlands"><img src="images/flags/nl.png"></a></li>
                                            <li><a href="/language?lang=en" title="English"><img src="images/flags/uk.png"></a></li>
                                            <c:choose>
                                                <c:when test="${loggedin eq 'true'}">
                                                    <li><a href="/logout" id="toggleLogout" >
                                                            <jsp:setProperty name="inhoud" property="key" value="LogOut" />
                                                            <jsp:getProperty name="inhoud" property="key" />
                                                        </a></li>
                                                    <li><a href="/${omgeving}" >
                                                            <jsp:setProperty name="inhoud" property="key" value="BackTo" />
                                                            <jsp:getProperty name="inhoud" property="key" /> ${omgeving}
                                                            <jsp:setProperty name="inhoud" property="key" value="TheEnvironment" />
                                                            <jsp:getProperty name="inhoud" property="key" />
                                                        </a></li>
                                                        <li><h2><jsp:setProperty name="inhoud" property="key" value="Welcome" />
                                                                <jsp:getProperty name="inhoud" property="key" />, ${user.firstName} ${user.lastName}</h2></li>
                                                            </c:when>
                                                    <c:otherwise>
                                                    <li><a href="#" id="toggleLogin" >
                                                            <jsp:setProperty name="inhoud" property="key" value="Login" />
                                                            <jsp:getProperty name="inhoud" property="key" />
                                                        </a></li>
                                                    </c:otherwise>
                                                </c:choose>                        
                                        </ul>
                                    </div>
                                    <div class="middle">
                                        <div id="menu">
                                            <ul>
                                                <li><a href="/index">
                                                        <jsp:setProperty name="inhoud" property="key" value="Homepage" />
                                                        <jsp:getProperty name="inhoud" property="key" />
                                                    </a></li>
                                                <li><a href="/courses">
                                                        <jsp:setProperty name="inhoud" property="key" value="Courses" />
                                                        <jsp:getProperty name="inhoud" property="key" />
                                                    </a></li>

                                                <li><a href="three2Learn.jsp">Three2Learn</a></li>
                                                <li><a href="information.jsp">

                                                        <jsp:setProperty name="inhoud" property="key" value="Information" />

                                                        <jsp:getProperty name="inhoud" property="key" />
                                                    </a></li>
                                                <li><a href="faq.jsp">

                                                        <jsp:setProperty name="inhoud" property="key" value="FAQ" />
                                                        <jsp:getProperty name="inhoud" property="key" />
                                                    </a></li>

                                                <li><a href="contact.jsp" class="lastItem">Contact</a></li>

                                            </ul>
                                        </div>
                                    </div>
                                </div>

                                <div id="subcontainer">
                                    <!--deel voor popup!-->
                                    <div id="overlay" class="web_dialog_overlay"></div>

                                    <div id="dialog" class="web_dialog">
                                        <table style="width: 100%; border: 0px;">
                                            <form method="post" action="/forum/new">
                                                <th colspan="2">
                                                    Add New Topic
                                                    <a id="closeNewTopic"href="#" class="button float">Close</a>
                                                </th>
                                                <tr><td class="darker">
                                                        <jsp:setProperty name="inhoud" property="key" value="TitleTopic" />
                                                            <jsp:getProperty name="inhoud" property="key" />
                                                    </td></tr>
                                                <tr>
                                                    <td width="100%"><input type="text" style="width:100%" name="title" /></td>
                                                </tr>
                                                <tr><td class="darker">
                                                        <jsp:setProperty name="inhoud" property="key" value="Content" />
                                                            <jsp:getProperty name="inhoud" property="key" />
                                                    </td></tr>
                                                <tr><td>
                                                        <textarea name="description" cols="25" rows="5"></textarea>
                                                        <input type="hidden" name="courseID" value="${course.courseID}" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="darker" colspan="2">
                                                        <input type="submit" value="Save" />
                                                    </td>
                                                </tr>
                                            </form>
                                        </table>
                                    </div>

                                    <c:choose>
                                        <c:when test="${not empty course}">
                                            <c:choose>
                                                <c:when test="${not empty questionID}">
                                                    <center>
                                                        <h1>
                                                            Forum: ${course.name}
                                                        </h1>
                                                        <a href="/studentcourse?courseID=${course.courseID}"><img src="style/icons/return.png"/></a>
                                                    </center>
                                                    <table width="100%">
                                                        <th colspan="2">
                                                                <jsp:setProperty name="inhoud" property="key" value="Posts" />
                                                            <jsp:getProperty name="inhoud" property="key" /> ${question.title}</td></th>
                                                            <tr class="darker">
                                                                <td ><b>
                                                                    <jsp:setProperty name="inhoud" property="key" value="Author" />
                                                                    <jsp:getProperty name="inhoud" property="key" /></b>
                                                                </td>
                                                                <td> <b><jsp:setProperty name="inhoud" property="key" value="Content" />
                                                            <jsp:getProperty name="inhoud" property="key" /></b></td>
                                                            </tr>
                                                        <tr>
                                                            <td>
                                                                <b>
                                                                    <jsp:setProperty name="inhoud" property="key" value="PlacedBy" />
                                                                <jsp:getProperty name="inhoud" property="key" /> :</b> ${question.questionPoster.firstName} ${question.questionPoster.lastName}
                                                                
                                                            </br>
                                                            <b>
                                                                <jsp:setProperty name="inhoud" property="key" value="ForumDate" />
                                                                <jsp:getProperty name="inhoud" property="key" /> :</b> ${question.questionDate}
                                                            
                                                            </td>
                                                            <td width="80%"height="30px" >${question.description}</td>
                                                        </tr>
                                                        <c:if test="${not empty answers}">
                                                            <c:forEach var="answer" items="${answers}">
                                                                <tr>
                                                                    <td >
                                                                        <b><jsp:setProperty name="inhoud" property="key" value="PlacedBy" />
                                                                        <jsp:getProperty name="inhoud" property="key" /> :</b> ${answer.answerPoster.firstName} ${answer.answerPoster.lastName}
                                                                    </br>
                                                                    <b><jsp:setProperty name="inhoud" property="key" value="ForumDate" />
                                                                        <jsp:getProperty name="inhoud" property="key" /> :</b> ${answer.answerDate}
                                                                    </td>
                                                                    <td width="80%">${answer.answer}</td>
                                                                </tr>
                                                            </c:forEach>
                                                    </c:if>
                                                    </table>

                                                    
                                                        <table width="100%">
                                                        <form action="/forum" method="post">
                                                            <tr><td class="darker">
                                                                    <h3><jsp:setProperty name="inhoud" property="key" value="NewAnswer" />
                                                                <jsp:getProperty name="inhoud" property="key" /> </h3>
                                                                </td></tr>
                                                                <tr><td><textarea style="width: 100%;" name="answerPost"></textarea></td></tr>
                                                            <input type="hidden" name="questionID" value="${questionID}"/>
                                                            <tr><td><input type="submit" value="Save"/>
                                                            </td></tr>
                                                        </form>
                                                        </table>
                                                </c:when>
                                                <c:otherwise>
                                                    <center>
                                                        <h1>
                                                            Forum: ${course.name}
                                                        </h1>
                                                        <a href="/studentcourse?courseID=${course.courseID}"><img src="style/icons/return.png"/></a>
                                                    </center>
                                                    <table width="100%">
                                                        <th colspan="3">
                                                            All Topics                                                            
                                                            <a id="newTopic"class="button float" href="#">
                                                                <jsp:setProperty name="inhoud" property="key" value="NewPost" />
                                                                <jsp:getProperty name="inhoud" property="key" /> 
                                                            </a>                                                            
                                                        </th>
                                                        <tr class="darker"><td><b>Title</b></td><td><b>Author</b></td><td><b>Posted On</b></td>
                                                        </tr>
                                                        <c:forEach var="question" items="${questions}">
                                                            <tr>
                                                                <td width="70%">
                                                                    <a href="/forum?courseID=${course.courseID}&questionID=${question.questionID}">${question.title}</a>
                                                                </td>  
                                                                <td>
                                                                    <jsp:setProperty name="inhoud" property="key" value="PlacedBy" />
                                                                    <jsp:getProperty name="inhoud" property="key" /> : ${question.questionPoster.firstName} ${question.questionPoster.lastName}
                                                                </td>
                                                                <td>
                                                                    <jsp:setProperty name="inhoud" property="key" value="ForumDate" />
                                                                    <jsp:getProperty name="inhoud" property="key" /> : ${question.questionDate}                                                                    
                                                                </td>
                                                            </tr>
                                                        </c:forEach>
                                                    </table>
                                                </c:otherwise>
                                            </c:choose>
                                        </c:when>
                                        <c:otherwise>
                                            <c:choose>
                                                <c:when test="${not empty courses}">
                                                    <h1>Forum</h1>
                                                    <h2><jsp:setProperty name="inhoud" property="key" value="Courses" />
                                                        <jsp:getProperty name="inhoud" property="key" /> </h2>
                                                    <table>
                                                        <c:forEach var="course" items="${courses}">
                                                            <tr><td><a href="/forum?courseID=${course.courseID}">${course.name}</a></td></tr>
                                                        </c:forEach>
                                                    </table>
                                                </c:when>
                                            </c:choose>
                                        </c:otherwise>
                                    </c:choose>
                                </div>

                            </div>
                        </div>
                    </body>
                    </html>
